package cn.shop.dys.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.BitmapDisplayConfig;

import cn.shop.dys.R;
import cn.shop.dys.constant.CommonConstant;

/**
 * 作者：jian on 2016/4/22 10:45
 * 孙建
 */
public class SingleIndentItem extends FrameLayout{

    private ImageView mImg;
    private TextView mName;
    private TextView mPrice;
    private TextView mStyle;
    private TextView mCount;
    private BitmapUtils mBitmapUtils;
    private BitmapDisplayConfig mDisplayConfig;

    public SingleIndentItem(Context context) {
        this(context,null);
    }

    public SingleIndentItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();

    }

    private void init() {
        mBitmapUtils = new BitmapUtils(getContext());
        View.inflate(getContext(), R.layout.indent_single_item,this);
        mImg = (ImageView) findViewById(R.id.iv_indent_img);
        mName = (TextView) findViewById(R.id.tv_product_name);
        mPrice = (TextView) findViewById(R.id.tv_indent_price);
        mStyle = (TextView) findViewById(R.id.tv_product_style);
        mCount = (TextView) findViewById(R.id.tv_indent_count);
        mDisplayConfig = new BitmapDisplayConfig();
        mDisplayConfig.setShowOriginal(true);
        mDisplayConfig.setBitmapConfig(Bitmap.Config.RGB_565);
    }
    public void setIndentImage(String url){
        mBitmapUtils.display(mImg, CommonConstant.HOST+url,mDisplayConfig);
    }
    public void setIndentName(String name){
        mName.setText(name);
    }
    public void setIndentPrice(String price){
        mPrice.setText(price);
    }
    public void setIndentStyle(String style){
        mStyle.setText("规格:"+style);
    }
    public void setIndentCount(String count){
        mCount.setText("x"+count);
    }
}
